<?php

namespace app\index\controller;

use think\Controller;
use app\admin\model\Course;
use app\admin\model\Advert;
use app\admin\model\Category;
use app\admin\model\Notice;

class Index extends Controller
{

    public function index()
    {
        //轮播图
        $adverts = Advert::with('photos')->limit(4)->select();
        //课程发布日历
        $course_times = Course::with('photo')->order('created_at','desc')->limit(6)->select();
        //最受欢迎的课程
        $course_bests = Course::with('photo')->where('publish',1)->order('likes_count','desc')->limit(5)->select();
        //入门课程
        $course_ins = Advert::with('photos')->where('advertisement_node_id',2)->limit(5)->select();
        //所有课程分类
        $categories =Category::all();
        //最新通知
        $notice_news = Notice::order('create_time','desc')->limit(3)->select();

        return view('/index',compact('course_bests','course_times','adverts','course_ins','categories','notice_news'));

    }


}
